package com.wx.plugin.mvc;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;

@Controller
public class HelloworldController {


    @RequestMapping("/")
    @ResponseBody
    String home() {
        return "hello world!";
    }
    @RequestMapping("/auth_url/{url}")
    @ResponseBody
    String auth_url(@PathVariable("url") String url) {
        String result = "none";
        try {
            String encode = URLEncoder.encode(url, "UTF-8");
            result = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxffdc11c6b2845b78&redirect_uri="+encode+"&response_type=code&scope=snsapi_base&state=STATE#wechat_redirect";
            return result;
        } catch (UnsupportedEncodingException e) {
            throw new RuntimeException(e);
        }
    }



}
